package org.oschina.handler;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import org.aspectj.lang.ProceedingJoinPoint;
import org.oschina.util.ReflectUtil;

public class BaseAopHandler {

	/**
	 * 获得方法
	 * @param proceedingJoinPoint
	 * @return
	 */
	protected Method getMethod(ProceedingJoinPoint proceedingJoinPoint)
	{
		return ReflectUtil.getMethodByClass(proceedingJoinPoint.getTarget().getClass(),proceedingJoinPoint.getSignature().getName(),proceedingJoinPoint.getArgs());
	}
	
	/**
	 * 获得注解
	 * @param proceedingJoinPoint
	 * @param annotation
	 * @return
	 */
	protected Annotation getAnnotation(ProceedingJoinPoint proceedingJoinPoint,Class annotation)
	{
		return ReflectUtil.getAnnotationByMethod(getMethod(proceedingJoinPoint), annotation);
	}
}